import java.util.Arrays;
import java.util.Scanner;

public class demo06 {
    public static int index=0;
    public static int count=-1;
    public static String str;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        str=sc.nextLine();
        char[] arr=str.toCharArray();
        Arrays.sort(arr);
        dfs(arr,0,arr.length-1);
        System.out.println(index);
    }
    public static void dfs(char[] arr,int left,int right){
        if(left==right){
            String s1="";
            for (int i = 0; i < arr.length; i++) {
                s1+=arr[i];
            }
            count++;
            if(s1.equals(str)){
                index=count;
                return;
            }
        }
        for (int i = left; i <= right; i++) {
            swap(arr,i,left);
            dfs(arr,left+1,right);
            swap(arr,i,left);
        }
    }
    public static void swap(char[] arr,int i,int j) {
        char tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }
}
